/**
 * @author LKQ
 * @date 2022/2/18 11:14
 * @description
 */
public class Solution {
    public static void main(String[] args) {
        Solution solution = new Solution();
        int[][] edges = {{1,2}, {2,3}, {4,2}};
        solution.findCenter(edges);
    }

    public int findCenter(int[][] edges) {
        int n = edges.length + 1;
        int[] cnt = new int[n + 1];
        for (int[] edge: edges) {
            cnt[edge[0]]++;
            cnt[edge[1]]++;
        }
        int ans = 0;
        for (int i = 1; i <= n; i++) {
            if (cnt[i] > 1) {
                ans = i;
                break;
            }
        }
        return ans;
    }
}
